/*
 * Copyright (c) 2023, 2024,yzc.cn All rights reserved.
 *
 */
package com.by.mq.consumer;

import com.by.common.utils.AutoCode;
import com.by.common.utils.AutoData;
import com.by.mapper.FinReturnPlanMapper;
import com.by.pojo.FinReturnPlan;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.HashMap;

/**
 * <p>Project: erp-cloud-api - FinReturnPlanMQConsumer</p>
 * <p>Powered by yzc On 2024-01-18 15:12:37</p>
 * <p>描述：<p>
 *
 * @author yzc [yzc0415@126.com]
 * @version 1.0
 * @since 17
 */
@Component
public class FinReturnPlanMQConsumer {

    @Autowired
    FinReturnPlanMapper finReturnPlanMapper;

    @RabbitListener(queues = {"purReturnQueue"})
    public  void handlerFinReturnPlan(HashMap<String,Object> hashMap){
        String code = AutoCode.autoCodePrefix("退款计划")+ AutoData.getNowData();
        String  maxCode = finReturnPlanMapper.maxCode(code);
        String newCode = AutoCode.getNewCode(maxCode,code);
        FinReturnPlan finReturnPlan = new FinReturnPlan();
        finReturnPlan.setCode(newCode);
        finReturnPlan.setReturnCode(hashMap.get("returnCode").toString());
        finReturnPlan.setSubject(hashMap.get("subject").toString());
        finReturnPlanMapper.insert(finReturnPlan);
    }

}
